<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   机器学习系列(3)_逻辑回归应用之Kaggle泰坦尼克之灾  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/21477.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466457459: Accept with keywords: (title(0.166666666667):逻辑,回归,数盟,泰坦尼克,社区,之灾, topn(0.333333333333):概率,人工智能,数盟,图表,数据挖掘,性别,集上,颜色,结果,乘客,模型,港口,参数,文章,情况,数据,属性,场景,预测,建模,问题,算法,拟合,年龄,人数,类目,交叉,数值,特征,字段).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    机器学习系列(3)_逻辑回归应用之Kaggle泰坦尼克之灾
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    机器学习系列(3)_逻辑回归应用之Kaggle泰坦尼克之灾 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,76] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/ai">
       人工智能
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/21477.html">
          机器学习系列(3)_逻辑回归应用之Kaggle泰坦尼克之灾
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,660 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/ai" rel="category tag">
          人工智能
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <div class="markdown_views">
        <h2 id="1引言">
         1.引言
        </h2>
        <p>
         先说一句，年末双十一什么的一来，真是非(mang)常(cheng)欢(gou)乐(le)！然后push自己抽出时间来写这篇blog的原因也非常简单：
        </p>
        <ul>
         <li>
          写完前两篇逻辑回归的介绍和各个角度理解之后，小伙伴们纷纷表示『好像很高级的样纸，but**_然并卵_**啊！你们倒是拿点实际数据来给我们看看，这玩意儿 有！什！么！用！啊！』
         </li>
         <li>
          talk is cheap, show me the code！
         </li>
         <li>
          no example say a jb！
         </li>
        </ul>
        <p>
         OK，OK，这就来了咯，同学们别着急，我们先找个简单的实际例子，来看看，所谓的
         <strong>
          数据挖掘
         </strong>
         或者
         <strong>
          机器学习实际应用
         </strong>
         到底是怎么样一个过程。
        </p>
        <p>
         『喂，那几个说要看大数据上机器学习应用的，对，就是说你们！别着急好么，我们之后拉点大一点实际数据用
         <a href="http://www.csie.ntu.edu.tw/%7Ecjlin/liblinear/">
          liblinear
         </a>
         或者
         <a href="http://spark.apache.org/mllib/">
          spark,MLlib
         </a>
         跑给你们看，行不行？咱们先拿个实例入入门嘛』
        </p>
        <p>
         好了，我是一个严肃的技术研究和分享者，咳咳，不能废话了，各位同学继续往下看吧！
        </p>
        <h2 id="2背景">
         2.背景
        </h2>
        <h3 id="21-关于kaggle">
         2.1 关于Kaggle
        </h3>
        <ul>
         <li>
          <a href="https://www.kaggle.com/">
           我是Kaggle地址，翻我牌子
          </a>
         </li>
         <li>
          亲，逼格这么高的地方，你一定听过对不对？是！这就是那个无数『数据挖掘先驱』们，在回答\”枪我有了，哪能找到靶子练练手啊？\”时候的答案！
         </li>
         <li>
          这是一个要数据有数据，要实际应用场景有场景，要一起在数据挖掘领域high得不要不要的小伙伴就有小伙伴的地方啊！！！
         </li>
        </ul>
        <p>
         艾玛，逗逼模式开太猛了。恩，不闹，不闹，说正事，Kaggle是一个数据分析建模的应用竞赛平台，有点类似
         <a href="http://www.kdd.org/">
          KDD-CUP
         </a>
         （国际知识发现和数据挖掘竞赛），企业或者研究者可以将问题
         <strong>
          背景、数据、期望指标
         </strong>
         等发布到Kaggle上，以竞赛的形式向广大的数据科学家征集解决方案。而热爱数(dong)据(shou)挖(zhe)掘(teng)的小伙伴们可以
         <em>
          下载/分析数据
         </em>
         ，使用统计/机器学习/数据挖掘等知识，建立算法模型，得出结果并提交，排名top的可能会有奖金哦！
        </p>
        <h3 id="22-关于泰坦尼克号之灾">
         2.2 关于泰坦尼克号之灾
        </h3>
        <ul>
         <li>
          带大家去
          <a href="https://www.kaggle.com/c/titanic">
           该问题页面
          </a>
          溜达一圈吧
         </li>
         <li>
          下面是问题背景页
          <br/>
          <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/2.jpeg?imageView/2/w/700/q/100"/>
         </li>
         <li>
          下面是可下载Data的页面
          <br/>
          <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/3.png?imageView/2/w/700/q/100"/>
         </li>
         <li>
          下面是小伙伴们最爱的forum页面，你会看到各种神级人物厉(qi)害(pa)的数据处理/建模想法，你会直视『世界真奇妙』。
          <br/>
          <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/4.png?imageView/2/w/700/q/100"/>
         </li>
         <li>
          泰坦尼克号问题之背景
         </li>
         <li>
          就是那个大家都熟悉的『Jack and Rose』的故事，豪华游艇倒了，大家都惊恐逃生，可是救生艇的数量有限，无法人人都有，副船长发话了『lady and kid first！』，所以
          <strong>
           是否获救其实并非随机，而是基于一些背景有rank先后的
          </strong>
          。
         </li>
         <li>
          训练和测试数据是一些乘客的个人信息以及存活状况，要尝试根据它生成合适的模型并
          <strong>
           预测其他人的存活状况
          </strong>
          。
         </li>
         <li>
          对，这是一个
          <strong>
           二分类
          </strong>
          问题，是我们之前讨论的
          <strong>
           logistic regression
          </strong>
          所能处理的范畴。
         </li>
        </ul>
        <h2 id="3说明">
         3.说明
        </h2>
        <p>
         接触过Kaggle的同学们可能知道这个问题，也可能知道RandomForest和SVM等等算法，甚至还对多个模型做过融合，取得过非常好的结果，那maybe这篇文章并不是针对你的，你可以自行略过。
        </p>
        <p>
         我们因为之前只介绍了Logistic Regression这一种分类算法。所以本次的问题解决过程和优化思路，都集中在这种算法上。其余的方法可能我们之后的文章里会提到。
        </p>
        <p>
         说点个人的观点。不一定正确。
         <br/>
         <strong>
          『解决一个问题的方法和思路不止一种』
         </strong>
         <br/>
         <strong>
          『没有所谓的机器学习算法优劣，也没有绝对高性能的机器学习算法，只有在特定的场景、数据和特征下更合适的机器学习算法。』
         </strong>
        </p>
        <h2 id="4怎么做">
         4.怎么做？
        </h2>
        <p>
         手把手教程马上就来，先来两条我看到的，觉得很重要的经验。
        </p>
        <ol>
         <li>
          印象中Andrew Ng老师似乎在coursera上说过，应用机器学习，千万不要一上来就试图做到完美，
          <strong>
           先撸一个baseline的model出来，再进行后续的分析步骤，一步步提高
          </strong>
          ，所谓后续步骤可能包括『分析model现在的状态(欠/过拟合)，分析我们使用的feature的作用大小，进行feature selection，以及我们模型下的bad case和产生的原因』等等。
         </li>
         <li>
          Kaggle上的大神们，也分享过一些experience，说几条我记得的哈：
          <ul>
           <li>
            <strong>
             『对数据的认识太重要了！』
            </strong>
           </li>
           <li>
            <strong>
             『数据中的特殊点/离群点的分析和处理太重要了！』
            </strong>
           </li>
           <li>
            <strong>
             『特征工程(feature engineering)太重要了！在很多Kaggle的场景下，甚至比model本身还要重要』
            </strong>
           </li>
           <li>
            <strong>
             『要做模型融合(model ensemble)啊啊啊！』
            </strong>
           </li>
          </ul>
         </li>
        </ol>
        <h2 id="5初探数据">
         5.初探数据
        </h2>
        <p>
         先看看我们的数据，长什么样吧。在Data下我们train.csv和test.csv两个文件，分别存着官方给的训练和测试数据。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad0c443419728" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; pandas &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; pd &lt;span class="hljs-comment"&gt;#数据分析&lt;/span&gt;
&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; numpy &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; np &lt;span class="hljs-comment"&gt;#科学计算&lt;/span&gt;
&lt;span class="hljs-keyword"&gt;from&lt;/span&gt; pandas &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; Series,DataFrame

data_train = pd.read_csv(&lt;span class="hljs-string"&gt;"/Users/Hanxiaoyang/Titanic_data/Train.csv"&lt;/span&gt;)
data_train
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad0c443419728-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad0c443419728-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad0c443419728-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad0c443419728-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad0c443419728-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad0c443419728-6">
                6
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad0c443419728-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pandas
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #数据分析&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad0c443419728-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 numpy
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #科学计算&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad0c443419728-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pandas
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 Series
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad0c443419728-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad0c443419728-5">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 read_csv
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "/Users/Hanxiaoyang/Titanic_data/Train.csv"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad0c443419728-6">
                <span class="crayon-v">
                 data_train
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0162 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
        </ul>
        <p>
         pandas是常用的python数据处理包，把csv文件读入成dataframe各式，我们在ipython notebook中，看到data_train如下所示：
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/5.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         这就是典型的dataframe格式，如果你没接触过这种格式，完全没有关系，你就把它想象成Excel里面的列好了。
         <br/>
         我们看到，总共有12列，其中Survived字段表示的是该乘客是否获救，其余都是乘客的个人信息，包括：
         <br/>
         * PassengerId =&gt; 乘客ID
         <br/>
         * Pclass =&gt; 乘客等级(1/2/3等舱位)
         <br/>
         * Name =&gt; 乘客姓名
         <br/>
         * Sex =&gt; 性别
         <br/>
         * Age =&gt; 年龄
         <br/>
         * SibSp =&gt; 堂兄弟/妹个数
         <br/>
         * Parch =&gt; 父母与小孩个数
         <br/>
         * Ticket =&gt; 船票信息
         <br/>
         * Fare =&gt; 票价
         <br/>
         * Cabin =&gt; 客舱
         <br/>
         * Embarked =&gt; 登船港口
        </p>
        <p>
         逐条往下看，要看完这么多条，眼睛都有一种要瞎的赶脚。好吧，我们让dataframe自己告诉我们一些信息，如下所示：
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad1f916187827" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           data_train.info()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad1f916187827-1">
                1
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad1f916187827-1">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 info
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0007 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
        </ul>
        <p>
         看到了如下的信息：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/6.png?imageView/2/w/500/q/100"/>
        </p>
        <p>
         上面的数据说啥了？它告诉我们，训练数据中总共有891名乘客，但是很不幸，我们有些属性的数据不全，比如说：
        </p>
        <ul>
         <li>
          Age（年龄）属性只有714名乘客有记录
         </li>
         <li>
          Cabin（客舱）更是只有204名乘客是已知的
         </li>
        </ul>
        <p>
         似乎信息略少啊，想再瞄一眼具体数据数值情况呢？恩，我们用下列的方法，得到数值型数据的一些分布(因为有些属性，比如姓名，是文本型；而另外一些属性，比如登船港口，是类目型。这些我们用下面的函数是看不到的)：
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/7.png?imageView/2/w/500/q/100"/>
        </p>
        <p>
         我们从上面看到更进一步的什么信息呢？
         <br/>
         mean字段告诉我们，大概0.383838的人最后获救了，2/3等舱的人数比1等舱要多，平均乘客年龄大概是29.7岁(计算这个时候会略掉无记录的)等等…
        </p>
        <h2 id="6数据初步分析">
         6.数据初步分析
        </h2>
        <p>
         每个乘客都这么多属性，那我们咋知道哪些属性更有用，而又应该怎么用它们啊？说实话这会儿我也不知道，但我们记得前面提到过
        </p>
        <ul>
         <li>
          <strong>
           『对数据的认识太重要了！』
          </strong>
         </li>
         <li>
          <strong>
           『对数据的认识太重要了！』
          </strong>
         </li>
         <li>
          <strong>
           『对数据的认识太重要了！』
          </strong>
         </li>
        </ul>
        <p>
         重要的事情说三遍，恩，说完了。仅仅最上面的对数据了解，依旧无法给我们提供想法和思路。我们再深入一点来看看我们的数据，看看
         <strong>
          每个/多个 属性和最后的Survived之间有着什么样的关系
         </strong>
         呢。
        </p>
        <h3 id="61-乘客各属性分布">
         6.1 乘客各属性分布
        </h3>
        <p>
         脑容量太有限了…数值看花眼了。我们还是统计统计，画些图来看看属性和结果之间的关系好了，代码如下：
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad2a987139668" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; matplotlib.pyplot &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; plt
fig = plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.2&lt;/span&gt;)  &lt;span class="hljs-comment"&gt;# 设定图表颜色alpha参数&lt;/span&gt;

plt.subplot2grid((&lt;span class="hljs-number"&gt;2&lt;/span&gt;,&lt;span class="hljs-number"&gt;3&lt;/span&gt;),(&lt;span class="hljs-number"&gt;0&lt;/span&gt;,&lt;span class="hljs-number"&gt;0&lt;/span&gt;))             &lt;span class="hljs-comment"&gt;# 在一张大图里分列几个小图&lt;/span&gt;
data_train.Survived.value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;)&lt;span class="hljs-comment"&gt;# 柱状图 &lt;/span&gt;
plt.title(&lt;span class="hljs-string"&gt;u"获救情况 (1为获救)"&lt;/span&gt;) &lt;span class="hljs-comment"&gt;# 标题&lt;/span&gt;
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;)  

plt.subplot2grid((&lt;span class="hljs-number"&gt;2&lt;/span&gt;,&lt;span class="hljs-number"&gt;3&lt;/span&gt;),(&lt;span class="hljs-number"&gt;0&lt;/span&gt;,&lt;span class="hljs-number"&gt;1&lt;/span&gt;))
data_train.Pclass.value_counts().plot(kind=&lt;span class="hljs-string"&gt;"bar"&lt;/span&gt;)
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"乘客等级分布"&lt;/span&gt;)

plt.subplot2grid((&lt;span class="hljs-number"&gt;2&lt;/span&gt;,&lt;span class="hljs-number"&gt;3&lt;/span&gt;),(&lt;span class="hljs-number"&gt;0&lt;/span&gt;,&lt;span class="hljs-number"&gt;2&lt;/span&gt;))
plt.scatter(data_train.Survived, data_train.Age)
plt.ylabel(&lt;span class="hljs-string"&gt;u"年龄"&lt;/span&gt;)                         &lt;span class="hljs-comment"&gt;# 设定纵坐标名称&lt;/span&gt;
plt.grid(b=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;, which=&lt;span class="hljs-string"&gt;'major'&lt;/span&gt;, axis=&lt;span class="hljs-string"&gt;'y'&lt;/span&gt;) 
plt.title(&lt;span class="hljs-string"&gt;u"按年龄看获救分布 (1为获救)"&lt;/span&gt;)


plt.subplot2grid((&lt;span class="hljs-number"&gt;2&lt;/span&gt;,&lt;span class="hljs-number"&gt;3&lt;/span&gt;),(&lt;span class="hljs-number"&gt;1&lt;/span&gt;,&lt;span class="hljs-number"&gt;0&lt;/span&gt;), colspan=&lt;span class="hljs-number"&gt;2&lt;/span&gt;)
data_train.Age[data_train.Pclass == &lt;span class="hljs-number"&gt;1&lt;/span&gt;].plot(kind=&lt;span class="hljs-string"&gt;'kde'&lt;/span&gt;)   
data_train.Age[data_train.Pclass == &lt;span class="hljs-number"&gt;2&lt;/span&gt;].plot(kind=&lt;span class="hljs-string"&gt;'kde'&lt;/span&gt;)
data_train.Age[data_train.Pclass == &lt;span class="hljs-number"&gt;3&lt;/span&gt;].plot(kind=&lt;span class="hljs-string"&gt;'kde'&lt;/span&gt;)
plt.xlabel(&lt;span class="hljs-string"&gt;u"年龄"&lt;/span&gt;)&lt;span class="hljs-comment"&gt;# plots an axis lable&lt;/span&gt;
plt.ylabel(&lt;span class="hljs-string"&gt;u"密度"&lt;/span&gt;) 
plt.title(&lt;span class="hljs-string"&gt;u"各等级的乘客年龄分布"&lt;/span&gt;)
plt.legend((&lt;span class="hljs-string"&gt;u'头等舱'&lt;/span&gt;, &lt;span class="hljs-string"&gt;u'2等舱'&lt;/span&gt;,&lt;span class="hljs-string"&gt;u'3等舱'&lt;/span&gt;),loc=&lt;span class="hljs-string"&gt;'best'&lt;/span&gt;) &lt;span class="hljs-comment"&gt;# sets our legend for our graph.&lt;/span&gt;


plt.subplot2grid((&lt;span class="hljs-number"&gt;2&lt;/span&gt;,&lt;span class="hljs-number"&gt;3&lt;/span&gt;),(&lt;span class="hljs-number"&gt;1&lt;/span&gt;,&lt;span class="hljs-number"&gt;2&lt;/span&gt;))
data_train.Embarked.value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"各登船口岸上船人数"&lt;/span&gt;)
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;)  
plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-28">
                28
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-29">
                29
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-30">
                30
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-31">
                31
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-32">
                32
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-33">
                33
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-34">
                34
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad2a987139668-35">
                35
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad2a987139668-36">
                36
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 matplotlib
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 pyplot
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 plt
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-2">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-3">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定图表颜色alpha参数&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-5">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 subplot2grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 在一张大图里分列几个小图&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-6">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 柱状图 &lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-7">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "获救情况 (1为获救)"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 标题&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-8">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-9">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-10">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 subplot2grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-11">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "bar"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-12">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-13">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "乘客等级分布"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-14">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-15">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 subplot2grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-16">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 scatter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-17">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "年龄"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定纵坐标名称&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-18">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 b
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 which
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'major'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'y'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-19">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "按年龄看获救分布 (1为获救)"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-20">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-21">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-22">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 subplot2grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 colspan
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-23">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'kde'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-24">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'kde'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-25">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'kde'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-26">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "年龄"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # plots an axis lable&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-27">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "密度"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-28">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "各等级的乘客年龄分布"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-29">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '头等舱'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '2等舱'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '3等舱'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'best'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # sets our legend for our graph.&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-30">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-31">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-32">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 subplot2grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-33">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Embarked
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-34">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "各登船口岸上船人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad2a987139668-35">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad2a987139668-36">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0963 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
         <li>
          21
         </li>
         <li>
          22
         </li>
         <li>
          23
         </li>
         <li>
          24
         </li>
         <li>
          25
         </li>
         <li>
          26
         </li>
         <li>
          27
         </li>
         <li>
          28
         </li>
         <li>
          29
         </li>
         <li>
          30
         </li>
         <li>
          31
         </li>
         <li>
          32
         </li>
         <li>
          33
         </li>
         <li>
          34
         </li>
         <li>
          35
         </li>
         <li>
          36
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/8.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         bingo，图还是比数字好看多了。所以我们在图上可以看出来，被救的人300多点，不到半数；3等舱乘客灰常多；遇难和获救的人年龄似乎跨度都很 广；3个不同的舱年龄总体趋势似乎也一致，2/3等舱乘客20岁多点的人最多，1等舱40岁左右的最多(→_→似乎符合财富和年龄的分配哈，咳咳，别理 我，我瞎扯的)；登船港口人数按照S、C、Q递减，而且S远多于另外俩港口。
        </p>
        <p>
         这个时候我们可能会有一些想法了：
         <br/>
         * 不同舱位/乘客等级可能和财富/地位有关系，最后获救概率可能会不一样
         <br/>
         * 年龄对获救概率也一定是有影响的，毕竟前面说了，副船长还说『小孩和女士先走』呢
         <br/>
         * 和登船港口是不是有关系呢？也许登船港口不同，人的出身地位不同？
        </p>
        <p>
         口说无凭，空想无益。老老实实再来统计统计，看看这些属性值的统计分布吧。
        </p>
        <h3 id="62-属性与获救结果的关联统计">
         6.2 属性与获救结果的关联统计
        </h3>
        <p>
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad38417262279" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-comment"&gt;#看看各乘客等级的获救情况&lt;/span&gt;
fig = plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.2&lt;/span&gt;)  &lt;span class="hljs-comment"&gt;# 设定图表颜色alpha参数&lt;/span&gt;

Survived_0 = data_train.Pclass[data_train.Survived == &lt;span class="hljs-number"&gt;0&lt;/span&gt;].value_counts()
Survived_1 = data_train.Pclass[data_train.Survived == &lt;span class="hljs-number"&gt;1&lt;/span&gt;].value_counts()
df=pd.DataFrame({&lt;span class="hljs-string"&gt;u'获救'&lt;/span&gt;:Survived_1, &lt;span class="hljs-string"&gt;u'未获救'&lt;/span&gt;:Survived_0})
df.plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, stacked=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"各乘客等级的获救情况"&lt;/span&gt;)
plt.xlabel(&lt;span class="hljs-string"&gt;u"乘客等级"&lt;/span&gt;) 
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;) 
plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad38417262279-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad38417262279-12">
                12
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad38417262279-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #看看各乘客等级的获救情况&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-2">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad38417262279-3">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定图表颜色alpha参数&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad38417262279-5">
                <span class="crayon-v">
                 Survived_0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-6">
                <span class="crayon-v">
                 Survived_1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad38417262279-7">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '获救'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_1
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '未获救'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_0
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-8">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 stacked
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad38417262279-9">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "各乘客等级的获救情况"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-10">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "乘客等级"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad38417262279-11">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad38417262279-12">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0306 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/9.png?imageView/2/w/450/q/100"/>
        </p>
        <p>
         啧啧，果然，钱和地位对舱位有影响，进而对获救的可能性也有影响啊←_←
         <br/>
         咳咳，跑题了，我想说的是，明显等级为1的乘客，获救的概率高很多。恩，这个一定是影响最后获救结果的一个特征。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad40178684428" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-comment"&gt;#看看各性别的获救情况&lt;/span&gt;
fig = plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.2&lt;/span&gt;)  &lt;span class="hljs-comment"&gt;# 设定图表颜色alpha参数&lt;/span&gt;

Survived_m = data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'male'&lt;/span&gt;].value_counts()
Survived_f = data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'female'&lt;/span&gt;].value_counts()
df=pd.DataFrame({&lt;span class="hljs-string"&gt;u'男性'&lt;/span&gt;:Survived_m, &lt;span class="hljs-string"&gt;u'女性'&lt;/span&gt;:Survived_f})
df.plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, stacked=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"按性别看获救情况"&lt;/span&gt;)
plt.xlabel(&lt;span class="hljs-string"&gt;u"性别"&lt;/span&gt;) 
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;)
plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad40178684428-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad40178684428-12">
                12
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad40178684428-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #看看各性别的获救情况&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-2">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad40178684428-3">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定图表颜色alpha参数&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad40178684428-5">
                <span class="crayon-v">
                 Survived_m
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'male'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-6">
                <span class="crayon-v">
                 Survived_f
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'female'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad40178684428-7">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '男性'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_m
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '女性'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_f
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-8">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 stacked
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad40178684428-9">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "按性别看获救情况"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-10">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "性别"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad40178684428-11">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad40178684428-12">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0279 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/10.png?imageView/2/w/450/q/100"/>
        </p>
        <p>
         歪果盆友果然很尊重lady，lady first践行得不错。性别无疑也要作为重要特征加入最后的模型之中。
        </p>
        <p>
         再来个详细版的好了。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad47394846769" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-comment"&gt;#然后我们再来看看各种舱级别情况下各性别的获救情况&lt;/span&gt;
fig=plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.65&lt;/span&gt;) &lt;span class="hljs-comment"&gt;# 设置图像透明度，无所谓&lt;/span&gt;
plt.title(&lt;span class="hljs-string"&gt;u"根据舱等级和性别的获救情况"&lt;/span&gt;)

ax1=fig.add_subplot(&lt;span class="hljs-number"&gt;141&lt;/span&gt;)
data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'female'&lt;/span&gt;][data_train.Pclass != &lt;span class="hljs-number"&gt;3&lt;/span&gt;].value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;"female highclass"&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;'#FA2479'&lt;/span&gt;)
ax1.set_xticklabels([&lt;span class="hljs-string"&gt;u"获救"&lt;/span&gt;, &lt;span class="hljs-string"&gt;u"未获救"&lt;/span&gt;], rotation=&lt;span class="hljs-number"&gt;0&lt;/span&gt;)
ax1.legend([&lt;span class="hljs-string"&gt;u"女性/高级舱"&lt;/span&gt;], loc=&lt;span class="hljs-string"&gt;'best'&lt;/span&gt;)

ax2=fig.add_subplot(&lt;span class="hljs-number"&gt;142&lt;/span&gt;, sharey=ax1)
data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'female'&lt;/span&gt;][data_train.Pclass == &lt;span class="hljs-number"&gt;3&lt;/span&gt;].value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;'female, low class'&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;'pink'&lt;/span&gt;)
ax2.set_xticklabels([&lt;span class="hljs-string"&gt;u"未获救"&lt;/span&gt;, &lt;span class="hljs-string"&gt;u"获救"&lt;/span&gt;], rotation=&lt;span class="hljs-number"&gt;0&lt;/span&gt;)
plt.legend([&lt;span class="hljs-string"&gt;u"女性/低级舱"&lt;/span&gt;], loc=&lt;span class="hljs-string"&gt;'best'&lt;/span&gt;)

ax3=fig.add_subplot(&lt;span class="hljs-number"&gt;143&lt;/span&gt;, sharey=ax1)
data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'male'&lt;/span&gt;][data_train.Pclass != &lt;span class="hljs-number"&gt;3&lt;/span&gt;].value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;'male, high class'&lt;/span&gt;,color=&lt;span class="hljs-string"&gt;'lightblue'&lt;/span&gt;)
ax3.set_xticklabels([&lt;span class="hljs-string"&gt;u"未获救"&lt;/span&gt;, &lt;span class="hljs-string"&gt;u"获救"&lt;/span&gt;], rotation=&lt;span class="hljs-number"&gt;0&lt;/span&gt;)
plt.legend([&lt;span class="hljs-string"&gt;u"男性/高级舱"&lt;/span&gt;], loc=&lt;span class="hljs-string"&gt;'best'&lt;/span&gt;)

ax4=fig.add_subplot(&lt;span class="hljs-number"&gt;144&lt;/span&gt;, sharey=ax1)
data_train.Survived[data_train.Sex == &lt;span class="hljs-string"&gt;'male'&lt;/span&gt;][data_train.Pclass == &lt;span class="hljs-number"&gt;3&lt;/span&gt;].value_counts().plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;'male low class'&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;'steelblue'&lt;/span&gt;)
ax4.set_xticklabels([&lt;span class="hljs-string"&gt;u"未获救"&lt;/span&gt;, &lt;span class="hljs-string"&gt;u"获救"&lt;/span&gt;], rotation=&lt;span class="hljs-number"&gt;0&lt;/span&gt;)
plt.legend([&lt;span class="hljs-string"&gt;u"男性/低级舱"&lt;/span&gt;], loc=&lt;span class="hljs-string"&gt;'best'&lt;/span&gt;)

plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad47394846769-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad47394846769-28">
                28
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad47394846769-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #然后我们再来看看各种舱级别情况下各性别的获救情况&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-3">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-4">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.65
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设置图像透明度，无所谓&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-5">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "根据舱等级和性别的获救情况"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-6">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-7">
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 add_subplot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 141
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-8">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'female'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 !=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "female highclass"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '#FA2479'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-9">
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set_xticklabels
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "未获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rotation
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-10">
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "女性/高级舱"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'best'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-11">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-12">
                <span class="crayon-v">
                 ax2
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 add_subplot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 142
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sharey
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-13">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'female'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'female, low class'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'pink'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-14">
                <span class="crayon-v">
                 ax2
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set_xticklabels
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "未获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rotation
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-15">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "女性/低级舱"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'best'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-16">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-17">
                <span class="crayon-v">
                 ax3
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 add_subplot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 143
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sharey
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-18">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'male'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 !=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'male, high class'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'lightblue'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-19">
                <span class="crayon-v">
                 ax3
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set_xticklabels
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "未获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rotation
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-20">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "男性/高级舱"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'best'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-21">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-22">
                <span class="crayon-v">
                 ax4
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 add_subplot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 144
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sharey
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 ax1
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-23">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'male'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'male low class'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'steelblue'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-24">
                <span class="crayon-v">
                 ax4
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set_xticklabels
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "未获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "获救"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rotation
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-25">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "男性/低级舱"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'best'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-26">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad47394846769-27">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad47394846769-28">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0853 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
         <li>
          21
         </li>
         <li>
          22
         </li>
         <li>
          23
         </li>
         <li>
          24
         </li>
         <li>
          25
         </li>
         <li>
          26
         </li>
         <li>
          27
         </li>
         <li>
          28
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/11.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         恩，坚定了之前的判断。
        </p>
        <p>
         我们看看各登船港口的获救情况。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad58882575123" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           fig = plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.2&lt;/span&gt;)  &lt;span class="hljs-comment"&gt;# 设定图表颜色alpha参数&lt;/span&gt;

Survived_0 = data_train.Embarked[data_train.Survived == &lt;span class="hljs-number"&gt;0&lt;/span&gt;].value_counts()
Survived_1 = data_train.Embarked[data_train.Survived == &lt;span class="hljs-number"&gt;1&lt;/span&gt;].value_counts()
df=pd.DataFrame({&lt;span class="hljs-string"&gt;u'获救'&lt;/span&gt;:Survived_1, &lt;span class="hljs-string"&gt;u'未获救'&lt;/span&gt;:Survived_0})
df.plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, stacked=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"各登录港口乘客的获救情况"&lt;/span&gt;)
plt.xlabel(&lt;span class="hljs-string"&gt;u"登录港口"&lt;/span&gt;) 
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;) 

plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad58882575123-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad58882575123-12">
                12
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad58882575123-1">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-2">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定图表颜色alpha参数&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad58882575123-3">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-4">
                <span class="crayon-v">
                 Survived_0
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Embarked
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad58882575123-5">
                <span class="crayon-v">
                 Survived_1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Embarked
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 ==
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-6">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '获救'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_1
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '未获救'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_0
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad58882575123-7">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 stacked
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-8">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "各登录港口乘客的获救情况"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad58882575123-9">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "登录港口"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-10">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad58882575123-11">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad58882575123-12">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0279 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/Embarked.png?imageView/2/w/500/q/100"/>
        </p>
        <p>
         下面我们来看看 堂兄弟/妹，孩子/父母有几人，对是否获救的影响。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad60197361423" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           g = data_train.groupby([&lt;span class="hljs-string"&gt;'SibSp'&lt;/span&gt;,&lt;span class="hljs-string"&gt;'Survived'&lt;/span&gt;])
df = pd.DataFrame(g.count()[&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;])
&lt;span class="hljs-keyword"&gt;print&lt;/span&gt; df

g = data_train.groupby([&lt;span class="hljs-string"&gt;'SibSp'&lt;/span&gt;,&lt;span class="hljs-string"&gt;'Survived'&lt;/span&gt;])
df = pd.DataFrame(g.count()[&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;])
&lt;span class="hljs-keyword"&gt;print&lt;/span&gt; df
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad60197361423-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad60197361423-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad60197361423-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad60197361423-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad60197361423-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad60197361423-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad60197361423-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad60197361423-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad60197361423-9">
                9
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad60197361423-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad60197361423-2">
                <span class="crayon-v">
                 g
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 groupby
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'SibSp'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad60197361423-3">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 g
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 count
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad60197361423-4">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 df
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad60197361423-5">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad60197361423-6">
                <span class="crayon-v">
                 g
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 groupby
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'SibSp'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad60197361423-7">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 g
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 count
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad60197361423-8">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-i">
                 df
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad60197361423-9">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0146 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/12.png?imageView/2/w/240/q/100"/>
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/13.png?imageView/2/w/240/q/100"/>
        </p>
        <p>
         好吧，没看出特别特别明显的规律(为自己的智商感到捉急…)，先作为备选特征，放一放。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad67227526011" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-comment"&gt;#ticket是船票编号，应该是unique的，和最后的结果没有太大的关系，先不纳入考虑的特征范畴把&lt;/span&gt;
&lt;span class="hljs-comment"&gt;#cabin只有204个乘客有值，我们先看看它的一个分布&lt;/span&gt;
data_train.Cabin.value_counts()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad67227526011-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad67227526011-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad67227526011-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad67227526011-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad67227526011-5">
                5
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad67227526011-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad67227526011-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #ticket是船票编号，应该是unique的，和最后的结果没有太大的关系，先不纳入考虑的特征范畴把&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad67227526011-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #cabin只有204个乘客有值，我们先看看它的一个分布&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad67227526011-4">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Cabin
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad67227526011-5">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0015 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
        </ul>
        <p>
         部分结果如下：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/14.png?imageView/2/w/240/q/100"/>
        </p>
        <p>
         这三三两两的…如此不集中…我们猜一下，也许，前面的ABCDE是指的甲板位置、然后编号是房间号？…好吧，我瞎说的，别当真…
        </p>
        <p>
         关键是Cabin这鬼属性，应该算作类目型的，本来缺失值就多，还如此不集中，注定是个棘手货…第一感觉，这玩意儿如果直接按照类目特征处理的话， 太散了，估计每个因子化后的特征都拿不到什么权重。加上有那么多缺失值，要不我们先把Cabin缺失与否作为条件(虽然这部分信息缺失可能并非未登 记，maybe只是丢失了而已，所以这样做未必妥当)，先在有无Cabin信息这个粗粒度上看看Survived的情况好了。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad6e003811477" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           fig = plt.figure()
fig.set(alpha=&lt;span class="hljs-number"&gt;0.2&lt;/span&gt;)  &lt;span class="hljs-comment"&gt;# 设定图表颜色alpha参数&lt;/span&gt;

Survived_cabin = data_train.Survived[pd.notnull(data_train.Cabin)].value_counts()
Survived_nocabin = data_train.Survived[pd.isnull(data_train.Cabin)].value_counts()
df=pd.DataFrame({&lt;span class="hljs-string"&gt;u'有'&lt;/span&gt;:Survived_cabin, &lt;span class="hljs-string"&gt;u'无'&lt;/span&gt;:Survived_nocabin}).transpose()
df.plot(kind=&lt;span class="hljs-string"&gt;'bar'&lt;/span&gt;, stacked=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
plt.title(&lt;span class="hljs-string"&gt;u"按Cabin有无看获救情况"&lt;/span&gt;)
plt.xlabel(&lt;span class="hljs-string"&gt;u"Cabin有无"&lt;/span&gt;) 
plt.ylabel(&lt;span class="hljs-string"&gt;u"人数"&lt;/span&gt;)
plt.show()
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad6e003811477-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad6e003811477-13">
                13
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-2">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-3">
                <span class="crayon-v">
                 fig
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 set
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 设定图表颜色alpha参数&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-5">
                <span class="crayon-v">
                 Survived_cabin
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 notnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Cabin
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-6">
                <span class="crayon-v">
                 Survived_nocabin
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Survived
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Cabin
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 value_counts
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-7">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '有'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_cabin
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 '无'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 Survived_nocabin
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 transpose
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-8">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 kind
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'bar'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 stacked
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-9">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "按Cabin有无看获救情况"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-10">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "Cabin有无"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-11">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "人数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad6e003811477-12">
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad6e003811477-13">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0198 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/15.png?imageView/2/w/400/q/100"/>
        </p>
        <p>
         咳咳，有Cabin记录的似乎获救概率稍高一些，先这么着放一放吧。
        </p>
        <h2 id="7简单数据预处理">
         7.简单数据预处理
        </h2>
        <p>
         大体数据的情况看了一遍，对感兴趣的属性也有个大概的了解了。
         <br/>
         下一步干啥？咱们该处理处理这些数据，为机器学习建模做点准备了。
        </p>
        <p>
         对了，我这里说的数据预处理，其实就包括了很多Kaggler津津乐道的feature engineering过程，灰常灰常有必要！
        </p>
        <p>
         <strong>
          『特征工程(feature engineering)太重要了！』
         </strong>
         <br/>
         <strong>
          『特征工程(feature engineering)太重要了！』
         </strong>
         <br/>
         <strong>
          『特征工程(feature engineering)太重要了！』
         </strong>
        </p>
        <p>
         恩，重要的事情说三遍。
        </p>
        <p>
         先从最突出的数据属性开始吧，对，Cabin和Age，有丢失数据实在是对下一步工作影响太大。
        </p>
        <p>
         先说Cabin，暂时我们就按照刚才说的，按Cabin有无数据，将这个属性处理成Yes和No两种类型吧。
        </p>
        <p>
         再说Age：
        </p>
        <p>
         通常遇到缺值的情况，我们会有几种常见的处理方式
        </p>
        <ul>
         <li>
          如果
          <strong>
           缺值的样本占总数比例极高
          </strong>
          ，我们可能就直接
          <strong>
           舍弃
          </strong>
          了，作为特征加入的话，可能反倒带入noise，影响最后的结果了
         </li>
         <li>
          如果缺值的样本适中，而该属性
          <strong>
           非连续值特征属性
          </strong>
          (比如说类目属性)，那就把NaN作为一个新类别，加到类别特征中
         </li>
         <li>
          如果缺值的样本适中，而该属性为
          <strong>
           连续值特征属性
          </strong>
          ，有时候我们会考虑给定一个step(比如这里的age，我们可以考虑每隔2/3岁为一个步长)，然后把它
          <strong>
           离散化
          </strong>
          ，之后把NaN作为一个type加到属性类目中。
         </li>
         <li>
          有些情况下，缺失的值个数并不是特别多，那我们也可以试着根据已有的值，拟合一下数据，补充上。
         </li>
        </ul>
        <p>
         本例中，后两种处理方式应该都是可行的，我们先试试拟合补全吧(虽然说没有特别多的背景可供我们拟合，这不一定是一个多么好的选择)
        </p>
        <p>
         我们这里用scikit-learn中的RandomForest来拟合一下缺失的年龄数据(注：RandomForest是一个用在原始数据中做 不同采样，建立多颗DecisionTree，再进行average等等来降低过拟合现象，提高结果的机器学习算法，我们之后会介绍到)
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad78366790620" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;from&lt;/span&gt; sklearn.ensemble &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; RandomForestRegressor

&lt;span class="hljs-comment"&gt;### 使用 RandomForestClassifier 填补缺失的年龄属性&lt;/span&gt;
&lt;span class="hljs-function"&gt;&lt;span class="hljs-keyword"&gt;def&lt;/span&gt; &lt;span class="hljs-title"&gt;set_missing_ages&lt;/span&gt;&lt;span class="hljs-params"&gt;(df)&lt;/span&gt;:&lt;/span&gt;

    &lt;span class="hljs-comment"&gt;# 把已有的数值型特征取出来丢进Random Forest Regressor中&lt;/span&gt;
    age_df = df[[&lt;span class="hljs-string"&gt;'Age'&lt;/span&gt;,&lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Parch'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'SibSp'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;]]

    &lt;span class="hljs-comment"&gt;# 乘客分成已知年龄和未知年龄两部分&lt;/span&gt;
    known_age = age_df[age_df.Age.notnull()].as_matrix()
    unknown_age = age_df[age_df.Age.isnull()].as_matrix()

    &lt;span class="hljs-comment"&gt;# y即目标年龄&lt;/span&gt;
    y = known_age[:, &lt;span class="hljs-number"&gt;0&lt;/span&gt;]

    &lt;span class="hljs-comment"&gt;# X即特征属性值&lt;/span&gt;
    X = known_age[:, &lt;span class="hljs-number"&gt;1&lt;/span&gt;:]

    &lt;span class="hljs-comment"&gt;# fit到RandomForestRegressor之中&lt;/span&gt;
    rfr = RandomForestRegressor(random_state=&lt;span class="hljs-number"&gt;0&lt;/span&gt;, n_estimators=&lt;span class="hljs-number"&gt;2000&lt;/span&gt;, n_jobs=-&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
    rfr.fit(X, y)

    &lt;span class="hljs-comment"&gt;# 用得到的模型进行未知年龄结果预测&lt;/span&gt;
    predictedAges = rfr.predict(unknown_age[:, &lt;span class="hljs-number"&gt;1&lt;/span&gt;::])

    &lt;span class="hljs-comment"&gt;# 用得到的预测结果填补原缺失数据&lt;/span&gt;
    df.loc[ (df.Age.isnull()), &lt;span class="hljs-string"&gt;'Age'&lt;/span&gt; ] = predictedAges 

    &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; df, rfr

&lt;span class="hljs-function"&gt;&lt;span class="hljs-keyword"&gt;def&lt;/span&gt; &lt;span class="hljs-title"&gt;set_Cabin_type&lt;/span&gt;&lt;span class="hljs-params"&gt;(df)&lt;/span&gt;:&lt;/span&gt;
    df.loc[ (df.Cabin.notnull()), &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt; ] = &lt;span class="hljs-string"&gt;"Yes"&lt;/span&gt;
    df.loc[ (df.Cabin.isnull()), &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt; ] = &lt;span class="hljs-string"&gt;"No"&lt;/span&gt;
    &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; df

data_train, rfr = set_missing_ages(data_train)
data_train = set_Cabin_type(data_train)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-28">
                28
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-29">
                29
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-30">
                30
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-31">
                31
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-32">
                32
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-33">
                33
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-34">
                34
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-35">
                35
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-36">
                36
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-37">
                37
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad78366790620-38">
                38
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad78366790620-39">
                39
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad78366790620-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 ensemble
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 RandomForestRegressor
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-3">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-4">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 ### 使用 RandomForestClassifier 填补缺失的年龄属性&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-5">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-function"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-title"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 set_missing_ages
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-params"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-6">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 把已有的数值型特征取出来丢进Random Forest Regressor中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 age_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Parch'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'SibSp'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-9">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 乘客分成已知年龄和未知年龄两部分&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 known_age
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 age_df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 age_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 notnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 unknown_age
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 age_df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 age_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-13">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # y即目标年龄&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-15">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 known_age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-16">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-17">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # X即特征属性值&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-18">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 known_age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-19">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-20">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # fit到RandomForestRegressor之中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-21">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 RandomForestRegressor
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 random_state
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_estimators
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2000
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_jobs
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-22">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-23">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-24">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 用得到的模型进行未知年龄结果预测&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-25">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 predictedAges
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 predict
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 unknown_age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 ::
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-26">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-27">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 用得到的预测结果填补原缺失数据&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-28">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 predictedAges
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-29">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-30">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-31">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-32">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-function"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-title"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 set_Cabin_type
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-params"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-33">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Cabin
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 notnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "Yes"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-34">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Cabin
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "No"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-35">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 df
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-36">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-37">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 set_missing_ages
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad78366790620-38">
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 set_Cabin_type
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad78366790620-39">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0677 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
         <li>
          21
         </li>
         <li>
          22
         </li>
         <li>
          23
         </li>
         <li>
          24
         </li>
         <li>
          25
         </li>
         <li>
          26
         </li>
         <li>
          27
         </li>
         <li>
          28
         </li>
         <li>
          29
         </li>
         <li>
          30
         </li>
         <li>
          31
         </li>
         <li>
          32
         </li>
         <li>
          33
         </li>
         <li>
          34
         </li>
         <li>
          35
         </li>
         <li>
          36
         </li>
         <li>
          37
         </li>
         <li>
          38
         </li>
         <li>
          39
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/16.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         恩。目的达到，OK了。
        </p>
        <p>
         因为逻辑回归建模时，需要输入的特征都是数值型特征，我们通常会先对类目型的特征因子化。
         <br/>
         什么叫做因子化呢？举个例子：
        </p>
        <p>
         以Cabin为例，原本一个属性维度，因为其取值可以是[‘yes’,’no’]，而将其平展开为’Cabin_yes’,’Cabin_no’两个属性
        </p>
        <ul>
         <li>
          原本Cabin取值为yes的，在此处的”Cabin_yes”下取值为1，在”Cabin_no”下取值为0
         </li>
         <li>
          原本Cabin取值为no的，在此处的”Cabin_yes”下取值为0，在”Cabin_no”下取值为1
         </li>
        </ul>
        <p>
         我们使用pandas的”get_dummies”来完成这个工作，并拼接在原来的”data_train”之上，如下所示。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad83671243262" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           dummies_Cabin = pd.get_dummies(data_train[&lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;)

dummies_Embarked = pd.get_dummies(data_train[&lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;)

dummies_Sex = pd.get_dummies(data_train[&lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;)

dummies_Pclass = pd.get_dummies(data_train[&lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;)

df = pd.concat([data_train, dummies_Cabin, dummies_Embarked, dummies_Sex, dummies_Pclass], axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
df.drop([&lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Name'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Ticket'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;], axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;, inplace=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
df
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad83671243262-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad83671243262-13">
                13
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad83671243262-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-2">
                <span class="crayon-v">
                 dummies_Cabin
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-3">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-4">
                <span class="crayon-v">
                 dummies_Embarked
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-5">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-6">
                <span class="crayon-v">
                 dummies_Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-7">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-8">
                <span class="crayon-v">
                 dummies_Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-9">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-10">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 concat
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_train
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Cabin
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Embarked
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Sex
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Pclass
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-11">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 drop
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Name'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Ticket'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 inplace
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad83671243262-12">
                <span class="crayon-i">
                 df
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad83671243262-13">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0388 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/17.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         bingo，我们很成功地把这些类目属性全都转成0，1的数值属性了。
        </p>
        <p>
         这样，看起来，是不是我们需要的属性值都有了，且它们都是数值型属性呢。
        </p>
        <p>
         有一种临近结果的宠宠欲动感吧，莫急莫急，我们还得做一些处理，仔细看看Age和Fare两个属性，乘客的数值幅度变化，也忒大了吧！！如果大家了解逻辑回归与梯度下降的话，会知道，各属性值之间scale差距太大，
         <strong>
          将对收敛速度造成几万点伤害值！甚至不收敛！
         </strong>
         (╬▔皿▔)…所以我们先用scikit-learn里面的preprocessing模块对这俩货做一个scaling，所谓scaling，其实就是将一些变化幅度较大的特征化到[-1,1]之内。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad8c761329474" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; sklearn.preprocessing &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; preprocessing
scaler = preprocessing.StandardScaler()
age_scale_param = scaler.fit(df[&lt;span class="hljs-string"&gt;'Age'&lt;/span&gt;])
df[&lt;span class="hljs-string"&gt;'Age_scaled'&lt;/span&gt;] = scaler.fit_transform(df[&lt;span class="hljs-string"&gt;'Age'&lt;/span&gt;], age_scale_param)
fare_scale_param = scaler.fit(df[&lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt;])
df[&lt;span class="hljs-string"&gt;'Fare_scaled'&lt;/span&gt;] = scaler.fit_transform(df[&lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt;], fare_scale_param)
df
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad8c761329474-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad8c761329474-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad8c761329474-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad8c761329474-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad8c761329474-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad8c761329474-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad8c761329474-7">
                7
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad8c761329474-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 preprocessing
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 preprocessing
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad8c761329474-2">
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 preprocessing
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 StandardScaler
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad8c761329474-3">
                <span class="crayon-v">
                 age_scale_param
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad8c761329474-4">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age_scaled'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit_transform
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 age_scale_param
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad8c761329474-5">
                <span class="crayon-v">
                 fare_scale_param
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad8c761329474-6">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare_scaled'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit_transform
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 fare_scale_param
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad8c761329474-7">
                <span class="crayon-v">
                 df
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0160 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/18.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         恩，好看多了，万事俱备，只欠建模。马上就要看到成效了，哈哈。我们把需要的属性值抽出来，转成scikit-learn里面LogisticRegression可以处理的格式。
        </p>
        <h2 id="8逻辑回归建模">
         8.逻辑回归建模
        </h2>
        <p>
         我们把需要的feature字段取出来，转成numpy格式，使用scikit-learn中的LogisticRegression建模。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad93974158880" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;from&lt;/span&gt; sklearn &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; linear_model

&lt;span class="hljs-comment"&gt;# 用正则取出我们要的属性值&lt;/span&gt;
train_df = df.filter(regex=&lt;span class="hljs-string"&gt;'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'&lt;/span&gt;)
train_np = train_df.as_matrix()

&lt;span class="hljs-comment"&gt;# y即Survival结果&lt;/span&gt;
y = train_np[:, &lt;span class="hljs-number"&gt;0&lt;/span&gt;]

&lt;span class="hljs-comment"&gt;# X即特征属性值&lt;/span&gt;
X = train_np[:, &lt;span class="hljs-number"&gt;1&lt;/span&gt;:]

&lt;span class="hljs-comment"&gt;# fit到RandomForestRegressor之中&lt;/span&gt;
clf = linear_model.LogisticRegression(C=&lt;span class="hljs-number"&gt;1.0&lt;/span&gt;, penalty=&lt;span class="hljs-string"&gt;'l1'&lt;/span&gt;, tol=&lt;span class="hljs-number"&gt;1e-6&lt;/span&gt;)
clf.fit(X, y)

clf
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad93974158880-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad93974158880-17">
                17
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad93974158880-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 linear_model
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-2">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 用正则取出我们要的属性值&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-4">
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-5">
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-6">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-7">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # y即Survival结果&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-8">
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-9">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-10">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # X即特征属性值&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-11">
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-12">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-13">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # fit到RandomForestRegressor之中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-14">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 linear_model
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 LogisticRegression
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 C
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 penalty
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'l1'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1e
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 6
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-15">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad93974158880-16">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad93974158880-17">
                <span class="crayon-v">
                 clf
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0297 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
        </ul>
        <p>
         good，很顺利，我们得到了一个model，如下：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/19.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         先淡定！淡定！你以为把test.csv直接丢进model里就能拿到结果啊…骚年，图样图森破啊！
         <strong>
          我们的”test_data”也要做和”train_data”一样的预处理啊！！
         </strong>
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daad9b281535228" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           data_test = pd.read_csv(&lt;span class="hljs-string"&gt;"/Users/Hanxiaoyang/Titanic_data/test.csv"&lt;/span&gt;)
data_test.loc[ (data_test.Fare.isnull()), &lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt; ] = &lt;span class="hljs-number"&gt;0&lt;/span&gt;
&lt;span class="hljs-comment"&gt;# 接着我们对test_data做和train_data中一致的特征变换&lt;/span&gt;
&lt;span class="hljs-comment"&gt;# 首先用同样的RandomForestRegressor模型填上丢失的年龄&lt;/span&gt;
tmp_df = data_test[[&lt;span class="hljs-string"&gt;'Age'&lt;/span&gt;,&lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Parch'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'SibSp'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;]]
null_age = tmp_df[data_test.Age.isnull()].as_matrix()
&lt;span class="hljs-comment"&gt;# 根据特征属性X预测年龄并补上&lt;/span&gt;
X = null_age[:, &lt;span class="hljs-number"&gt;1&lt;/span&gt;:]
predictedAges = rfr.predict(X)
data_test.loc[ (data_test.Age.isnull()), &lt;span class="hljs-string"&gt;'Age'&lt;/span&gt; ] = predictedAges

data_test = set_Cabin_type(data_test)
dummies_Cabin = pd.get_dummies(data_test[&lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;)
dummies_Embarked = pd.get_dummies(data_test[&lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;)
dummies_Sex = pd.get_dummies(data_test[&lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;)
dummies_Pclass = pd.get_dummies(data_test[&lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;], prefix= &lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;)


df_test = pd.concat([data_test, dummies_Cabin, dummies_Embarked, dummies_Sex, dummies_Pclass], axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
df_test.drop([&lt;span class="hljs-string"&gt;'Pclass'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Name'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Sex'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Ticket'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Cabin'&lt;/span&gt;, &lt;span class="hljs-string"&gt;'Embarked'&lt;/span&gt;], axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;, inplace=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;)
df_test[&lt;span class="hljs-string"&gt;'Age_scaled'&lt;/span&gt;] = scaler.fit_transform(df_test[&lt;span class="hljs-string"&gt;'Age'&lt;/span&gt;], age_scale_param)
df_test[&lt;span class="hljs-string"&gt;'Fare_scaled'&lt;/span&gt;] = scaler.fit_transform(df_test[&lt;span class="hljs-string"&gt;'Fare'&lt;/span&gt;], fare_scale_param)
df_test
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daad9b281535228-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daad9b281535228-25">
                25
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-1">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-2">
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 read_csv
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "/Users/Hanxiaoyang/Titanic_data/test.csv"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-3">
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Fare
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-4">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 接着我们对test_data做和train_data中一致的特征变换&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-5">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 首先用同样的RandomForestRegressor模型填上丢失的年龄&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-6">
                <span class="crayon-v">
                 tmp_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Parch'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'SibSp'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-7">
                <span class="crayon-v">
                 null_age
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tmp_df
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-8">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 根据特征属性X预测年龄并补上&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-9">
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 null_age
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-10">
                <span class="crayon-v">
                 predictedAges
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rfr
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 predict
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-11">
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 Age
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isnull
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 predictedAges
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-12">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-13">
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 set_Cabin_type
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-14">
                <span class="crayon-v">
                 dummies_Cabin
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-15">
                <span class="crayon-v">
                 dummies_Embarked
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-16">
                <span class="crayon-v">
                 dummies_Sex
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-17">
                <span class="crayon-v">
                 dummies_Pclass
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 get_dummies
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 prefix
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-18">
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-19">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-20">
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 concat
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Cabin
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Embarked
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Sex
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dummies_Pclass
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-21">
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 drop
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Pclass'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Name'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Sex'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Ticket'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Cabin'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Embarked'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 inplace
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-22">
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age_scaled'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit_transform
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 age_scale_param
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-23">
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare_scaled'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 scaler
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit_transform
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Fare'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 fare_scale_param
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daad9b281535228-24">
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 _
                </span>
                test
               </div>
               <div class="crayon-line" id="crayon-57685d6daad9b281535228-25">
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0927 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
         <li>
          21
         </li>
         <li>
          22
         </li>
         <li>
          23
         </li>
         <li>
          24
         </li>
         <li>
          25
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/20.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         不错不错，数据很OK，差最后一步了。
         <br/>
         下面就做预测取结果吧！！
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daada5990002704" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           test = df_test.filter(regex=&lt;span class="hljs-string"&gt;'Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'&lt;/span&gt;)
predictions = clf.predict(test)
result = pd.DataFrame({&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;:data_test[&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;].as_matrix(), &lt;span class="hljs-string"&gt;'Survived'&lt;/span&gt;:predictions.astype(np.int32)})
result.to_csv(&lt;span class="hljs-string"&gt;"/Users/Hanxiaoyang/Titanic_data/logistic_regression_predictions.csv"&lt;/span&gt;, index=&lt;span class="hljs-keyword"&gt;False&lt;/span&gt;)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daada5990002704-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daada5990002704-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daada5990002704-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daada5990002704-4">
                4
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daada5990002704-1">
                <span class="crayon-v">
                 test
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daada5990002704-2">
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 predict
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daada5990002704-3">
                <span class="crayon-v">
                 result
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 astype
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 int32
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daada5990002704-4">
                <span class="crayon-v">
                 result
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 to_csv
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "/Users/Hanxiaoyang/Titanic_data/logistic_regression_predictions.csv"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 index
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 False
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0264 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/21.png?imageView/2/w/240/q/100"/>
        </p>
        <p>
         啧啧，挺好，格式正确，去make a submission啦啦啦！
        </p>
        <p>
         在Kaggle的Make a submission页面，提交上结果。如下：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/result_2.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         0.76555，恩，结果还不错。毕竟，这只是我们简单分析处理过后出的一个baseline模型嘛。
        </p>
        <h2 id="9逻辑回归系统优化">
         9.逻辑回归系统优化
        </h2>
        <h3 id="91-模型系数关联分析">
         9.1 模型系数关联分析
        </h3>
        <p>
         亲，你以为结果提交上了，就完事了？
         <br/>
         我不会告诉你，这只是万里长征第一步啊(泪牛满面)！！！这才刚撸完baseline model啊！！！还得优化啊！！！
        </p>
        <p>
         看过Andrew Ng老师的machine Learning课程的同学们，知道，我们应该分析分析模型现在的状态了，是过/欠拟合？，以确定我们需要更多的特征还是更多数据，或者其他操作。我们有一条很著名的learning curves对吧。
        </p>
        <p>
         不过在现在的场景下，先不着急做这个事情，我们这个baseline系统还有些粗糙，先再挖掘挖掘。
        </p>
        <ul>
         <li>
          首先，Name和Ticket两个属性被我们完整舍弃了(好吧，其实是因为这俩属性，几乎每一条记录都是一个完全不同的值，我们并没有找到很直接的处理方式)。
         </li>
         <li>
          然后，我们想想，年龄的拟合本身也未必是一件非常靠谱的事情，我们依据其余属性，其实并不能很好地拟合预测出未知的年龄。再一个，以我们的 日常经验，小盆友和老人可能得到的照顾会多一些，这样看的话，年龄作为一个连续值，给一个固定的系数，应该和年龄是一个正相关或者负相关，似乎体现不出两 头受照顾的实际情况，所以，说不定我们把年龄离散化，按区段分作类别属性会更合适一些。
         </li>
        </ul>
        <p>
         上面只是我瞎想的，who knows是不是这么回事呢，老老实实先把得到的model系数和feature关联起来看看。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daadad772675752" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           pd.DataFrame({&lt;span class="hljs-string"&gt;"columns"&lt;/span&gt;:list(train_df.columns)[&lt;span class="hljs-number"&gt;1&lt;/span&gt;:], &lt;span class="hljs-string"&gt;"coef"&lt;/span&gt;:list(clf.coef_.T)})
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daadad772675752-1">
                1
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daadad772675752-1">
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "columns"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-e">
                 list
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 columns
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "coef"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-e">
                 list
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 coef_
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 T
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0140 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/22.png?imageView/2/w/220/q/100"/>
        </p>
        <p>
         首先，大家回去
         <a href="http://blog.csdn.net/han_xiaoyang/article/details/49123419">
          前两篇文章
         </a>
         里瞄一眼公式就知道，这些系数为正的特征，和最后结果是一个正相关，反之为负相关。
        </p>
        <p>
         我们先看看那些权重绝对值非常大的feature，在我们的模型上：
        </p>
        <ul>
         <li>
          Sex属性，如果是female会极大提高最后获救的概率，而male会很大程度拉低这个概率。
         </li>
         <li>
          Pclass属性，1等舱乘客最后获救的概率会上升，而乘客等级为3会极大地拉低这个概率。
         </li>
         <li>
          有Cabin值会很大程度拉升最后获救概率(
          <strong>
           这里似乎能看到了一点端倪，事实上从最上面的有无Cabin记录的Survived分布图上看出，即使有Cabin记录的乘客也有一部分遇难了，估计这个属性上我们挖掘还不够
          </strong>
          )
         </li>
         <li>
          Age是一个负相关，意味着在我们的模型里，年龄越小，越有获救的优先权(
          <strong>
           还得回原数据看看这个是否合理
          </strong>
          ）
         </li>
         <li>
          有一个登船港口S会很大程度拉低获救的概率，另外俩港口压根就没啥作用(
          <strong>
           这个实际上非常奇怪，因为我们从之前的统计图上并没有看到S港口的获救率非常低，所以也许可以考虑把登船港口这个feature去掉试试
          </strong>
          )。
         </li>
         <li>
          船票Fare有小幅度的正相关(
          <strong>
           并不意味着这个feature作用不大，有可能是我们细化的程度还不够，举个例子，说不定我们得对它离散化，再分至各个乘客等级上？
          </strong>
          )
         </li>
        </ul>
        <p>
         噢啦，观察完了，我们现在有一些想法了，但是怎么样才知道，哪些优化的方法是promising的呢？
        </p>
        <p>
         因为test.csv里面并没有Survived这个字段(好吧，这是废话，这明明就是我们要预测的结果)，我们无法在这份数据上评定我们算法在该场景下的效果…
        </p>
        <p>
         而『每做一次调整就make a submission，然后根据结果来判定这次调整的好坏』其实是行不通的…
        </p>
        <h3 id="92-交叉验证">
         9.2 交叉验证
        </h3>
        <p>
         重点又来了：
        </p>
        <p>
         <strong>
          『要做交叉验证(cross validation)!』
         </strong>
         <br/>
         <strong>
          『要做交叉验证(cross validation)!』
         </strong>
         <br/>
         <strong>
          『要做交叉验证(cross validation)!』
         </strong>
        </p>
        <p>
         恩，重要的事情说三遍。我们通常情况下，这么做cross validation：把train.csv分成两部分，一部分用于训练我们需要的模型，另外一部分数据上看我们预测算法的效果。
        </p>
        <p>
         我们用scikit-learn的cross_validation来帮我们完成小数据集上的这个工作。
        </p>
        <p>
         先简单看看cross validation情况下的打分
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daadb6073614953" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;from&lt;/span&gt; sklearn &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; cross_validation

 &lt;span class="hljs-comment"&gt;#简单看看打分情况&lt;/span&gt;
clf = linear_model.LogisticRegression(C=&lt;span class="hljs-number"&gt;1.0&lt;/span&gt;, penalty=&lt;span class="hljs-string"&gt;'l1'&lt;/span&gt;, tol=&lt;span class="hljs-number"&gt;1e-6&lt;/span&gt;)
all_data = df.filter(regex=&lt;span class="hljs-string"&gt;'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'&lt;/span&gt;)
X = all_data.as_matrix()[:,&lt;span class="hljs-number"&gt;1&lt;/span&gt;:]
y = all_data.as_matrix()[:,&lt;span class="hljs-number"&gt;0&lt;/span&gt;]
&lt;span class="hljs-keyword"&gt;print&lt;/span&gt; cross_validation.cross_val_score(clf, X, y, cv=&lt;span class="hljs-number"&gt;5&lt;/span&gt;)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daadb6073614953-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadb6073614953-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadb6073614953-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadb6073614953-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadb6073614953-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadb6073614953-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadb6073614953-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadb6073614953-8">
                8
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daadb6073614953-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cross_validation
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadb6073614953-2">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadb6073614953-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 #简单看看打分情况&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadb6073614953-4">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 linear_model
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 LogisticRegression
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 C
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 penalty
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'l1'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1e
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 6
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadb6073614953-5">
                <span class="crayon-v">
                 all_data
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadb6073614953-6">
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 all_data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadb6073614953-7">
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 all_data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadb6073614953-8">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cross_validation
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 cross_val_score
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cv
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0244 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
        </ul>
        <p>
         结果是下面酱紫的：
         <br/>
         [0.81564246 0.81005587 0.78651685 0.78651685 0.81355932]
        </p>
        <p>
         似乎比Kaggle上的结果略高哈，毕竟用的是不是同一份数据集评估的。
        </p>
        <p>
         等等，既然我们要做交叉验证，那我们干脆先把交叉验证里面的bad case拿出来看看，看看人眼审核，是否能发现什么蛛丝马迹，是我们忽略了哪些信息，使得这些乘客被判定错了。再把bad case上得到的想法和前头系数分析的合在一起，然后逐个试试。
        </p>
        <p>
         下面我们做数据分割，并且在原始数据集上瞄一眼bad case：
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daadbe117521794" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-comment"&gt;# 分割数据，按照 训练数据:cv数据 = 7:3的比例&lt;/span&gt;
split_train, split_cv = cross_validation.train_test_split(df, test_size=&lt;span class="hljs-number"&gt;0.3&lt;/span&gt;, random_state=&lt;span class="hljs-number"&gt;0&lt;/span&gt;)
train_df = split_train.filter(regex=&lt;span class="hljs-string"&gt;'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'&lt;/span&gt;)
&lt;span class="hljs-comment"&gt;# 生成模型&lt;/span&gt;
clf = linear_model.LogisticRegression(C=&lt;span class="hljs-number"&gt;1.0&lt;/span&gt;, penalty=&lt;span class="hljs-string"&gt;'l1'&lt;/span&gt;, tol=&lt;span class="hljs-number"&gt;1e-6&lt;/span&gt;)
clf.fit(train_df.as_matrix()[:,&lt;span class="hljs-number"&gt;1&lt;/span&gt;:], train_df.as_matrix()[:,&lt;span class="hljs-number"&gt;0&lt;/span&gt;])

&lt;span class="hljs-comment"&gt;# 对cross validation数据进行预测&lt;/span&gt;

cv_df = split_cv.filter(regex=&lt;span class="hljs-string"&gt;'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'&lt;/span&gt;)
predictions = clf.predict(cv_df.as_matrix()[:,&lt;span class="hljs-number"&gt;1&lt;/span&gt;:])

origin_data_train = pd.read_csv(&lt;span class="hljs-string"&gt;"/Users/HanXiaoyang/Titanic_data/Train.csv"&lt;/span&gt;)
bad_cases = origin_data_train.loc[origin_data_train[&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;].isin(split_cv[predictions != cv_df.as_matrix()[:,&lt;span class="hljs-number"&gt;0&lt;/span&gt;]][&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;].values)]
bad_cases
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadbe117521794-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadbe117521794-15">
                15
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 分割数据，按照 训练数据:cv数据 = 7:3的比例&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-2">
                <span class="crayon-v">
                 split_train
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 split_cv
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cross_validation
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 train_test_split
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_size
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 random_state
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-3">
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 split_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-4">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 生成模型&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-5">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 linear_model
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 LogisticRegression
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 C
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 penalty
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'l1'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1e
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 6
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-6">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-7">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-8">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 对cross validation数据进行预测&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-9">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-10">
                <span class="crayon-v">
                 cv_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 split_cv
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass_.*'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-11">
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 predict
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 cv_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-12">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-13">
                <span class="crayon-v">
                 origin_data_train
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 read_csv
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "/Users/HanXiaoyang/Titanic_data/Train.csv"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadbe117521794-14">
                <span class="crayon-v">
                 bad_cases
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 origin_data_train
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 origin_data_train
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 isin
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 split_cv
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 !=
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cv_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 values
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadbe117521794-15">
                <span class="crayon-v">
                 bad_cases
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0388 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
        </ul>
        <p>
         我们判定错误的 bad case 中部分数据如下：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/23.png?imageView/2/w/700/q/100"/>
        </p>
        <p>
         大家可以自己跑一遍试试，拿到bad cases之后，仔细看看。也会有一些猜测和想法。其中会有一部分可能会印证在系数分析部分的猜测，那这些优化的想法优先级可以放高一些。
        </p>
        <p>
         现在有了”train_df” 和 “vc_df” 两个数据部分，前者用于训练model，后者用于评定和选择模型。可以开始可劲折腾了。
        </p>
        <p>
         我们随便列一些可能可以做的优化操作：
         <br/>
         * Age属性不使用现在的拟合方式，而是根据名称中的『Mr』『Mrs』『Miss』等的平均值进行填充。
         <br/>
         * Age不做成一个连续值属性，而是使用一个步长进行离散化，变成离散的类目feature。
         <br/>
         * Cabin再细化一些，对于有记录的Cabin属性，我们将其分为前面的字母部分(我猜是位置和船层之类的信息) 和 后面的数字部分(应该是房间号，有意思的事情是，如果你仔细看看原始数据，你会发现，这个值大的情况下，似乎获救的可能性高一些)。
         <br/>
         * Pclass和Sex俩太重要了，我们试着用它们去组出一个组合属性来试试，这也是另外一种程度的细化。
         <br/>
         * 单加一个Child字段，Age&lt;=12的，设为1，其余为0(你去看看数据，确实小盆友优先程度很高啊)
         <br/>
         * 如果名字里面有『Mrs』，而Parch&gt;1的，我们猜测她可能是一个母亲，应该获救的概率也会提高，因此可以多加一个Mother字段，此种情况下设为1，其余情况下设为0
         <br/>
         * 登船港口可以考虑先去掉试试(Q和C本来就没权重，S有点诡异)
         <br/>
         * 把堂兄弟/兄妹 和 Parch 还有自己 个数加在一起组一个Family_size字段(考虑到大家族可能对最后的结果有影响)
         <br/>
         * Name是一个我们一直没有触碰的属性，我们可以做一些简单的处理，比如说男性中带某些字眼的(‘Capt’, ‘Don’, ‘Major’, ‘Sir’)可以统一到一个Title，女性也一样。
        </p>
        <p>
         大家接着往下挖掘，可能还可以想到更多可以细挖的部分。我这里先列这些了，然后我们可以使用手头上的”train_df”和”cv_df”开始试验这些feature engineering的tricks是否有效了。
        </p>
        <p>
         试验的过程比较漫长，也需要有耐心，而且我们经常会面临很尴尬的状况，就是我们灵光一闪，想到一个feature，然后坚信它一定有效，结果试验下来，效果还不如试验之前的结果。恩，需要坚持和耐心，以及不断的挖掘。
        </p>
        <p>
         我最好的结果是在『Survived~C(Pclass)+C(Title)+C(Sex)+C(Age_bucket)+C(Cabin_num_bucket)Mother+Fare+Family_Size』下取得的，结果如下(
         <strong>
          抱歉，博主君这次commit的时候手抖把页面关了，于是没截着图，下面这张图是在我得到最高分之后，用这次的结果重新make commission的，截了个图，不是目前我的最高分哈，因此排名木有变…
         </strong>
         )：
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/result_3.png?imageView/2/w/700/q/100"/>
        </p>
        <h3 id="93-learning-curves">
         9.3 learning curves
        </h3>
        <p>
         有一个很可能发生的问题是，我们不断地做feature engineering，产生的特征越来越多，用这些特征去训练模型，会
         <strong>
          对我们的训练集拟合得越来越好，同时也可能在逐步丧失泛化能力
         </strong>
         ，从而在待预测的数据上，表现不佳，也就是发生
         <strong>
          过拟合
         </strong>
         问题。
        </p>
        <p>
         从另一个角度上说，如果模型在待预测的数据上表现不佳，除掉上面说的过拟合问题，也有可能是欠拟合问题，也就是说在训练集上，其实拟合的也不是那么好。
        </p>
        <p>
         额，这个欠拟合和过拟合怎么解释呢。这么说吧：
        </p>
        <ul>
         <li>
          过拟合就像是你班那个学数学比较刻板的同学，老师讲过的题目，一字不漏全记下来了，于是老师再出一样的题目，分分钟精确出结果。but数学考试，因为总是碰到新题目，所以成绩不咋地。
         </li>
         <li>
          欠拟合就像是，咳咳，和博主level差不多的差生。连老师讲的练习题也记不住，于是连老师出一样题目复习的周测都做不好，考试更是可想而知了。
         </li>
        </ul>
        <p>
         而在机器学习的问题上，对于
         <strong>
          过拟合
         </strong>
         和
         <strong>
          欠拟合
         </strong>
         两种情形。我们优化的方式是不同的。
        </p>
        <p>
         对过拟合而言，通常以下策略对结果优化是有用的：
        </p>
        <ul>
         <li>
          做一下feature selection，挑出较好的feature的subset来做training
         </li>
         <li>
          提供更多的数据，从而弥补原始数据的bias问题，学习到的model也会更准确
         </li>
        </ul>
        <p>
         而对于欠拟合而言，我们通常需要更多的feature，更复杂的模型来提高准确度。
        </p>
        <p>
         著名的learning curve可以帮我们判定我们的模型现在所处的状态。我们以样本数为横坐标，训练和交叉验证集上的错误率作为纵坐标，两种状态分别如下两张图所示：过拟合 (overfitting/high variace)，欠拟合(underfitting/high bias)
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/high_variance.png?imageView/2/w/400/q/100"/>
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/high_bias.png?imageView/2/w/400/q/100"/>
        </p>
        <p>
         我们也可以把错误率替换成准确率(得分)，得到另一种形式的learning curve(sklearn 里面是这么做的)。
        </p>
        <p>
         回到我们的问题，我们用scikit-learn里面的learning_curve来帮我们分辨我们模型的状态。举个例子，这里我们一起画一下我们最先得到的baseline model的learning curve。
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daadcb155086021" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; numpy &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; np
&lt;span class="hljs-keyword"&gt;import&lt;/span&gt; matplotlib.pyplot &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; plt
&lt;span class="hljs-keyword"&gt;from&lt;/span&gt; sklearn.learning_curve &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; learning_curve

&lt;span class="hljs-comment"&gt;# 用sklearn的learning_curve得到training_score和cv_score，使用matplotlib画出learning curve&lt;/span&gt;
&lt;span class="hljs-function"&gt;&lt;span class="hljs-keyword"&gt;def&lt;/span&gt; &lt;span class="hljs-title"&gt;plot_learning_curve&lt;/span&gt;&lt;span class="hljs-params"&gt;(estimator, title, X, y, ylim=None, cv=None, n_jobs=&lt;span class="hljs-number"&gt;1&lt;/span&gt;, 
                        train_sizes=np.linspace(&lt;span class="hljs-number"&gt;.05&lt;/span&gt;, &lt;span class="hljs-number"&gt;1.&lt;/span&gt;, &lt;span class="hljs-number"&gt;20&lt;/span&gt;), verbose=&lt;span class="hljs-number"&gt;0&lt;/span&gt;, plot=True)&lt;/span&gt;:&lt;/span&gt;
    &lt;span class="hljs-string"&gt;"""
    画出data在某模型上的learning curve.
    参数解释
    ----------
    estimator : 你用的分类器。
    title : 表格的标题。
    X : 输入的feature，numpy类型
    y : 输入的target vector
    ylim : tuple格式的(ymin, ymax), 设定图像中纵坐标的最低点和最高点
    cv : 做cross-validation的时候，数据分成的份数，其中一份作为cv集，其余n-1份作为training(默认为3份)
    n_jobs : 并行的的任务数(默认1)
    """&lt;/span&gt;
    train_sizes, train_scores, test_scores = learning_curve(
        estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes, verbose=verbose)

    train_scores_mean = np.mean(train_scores, axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
    train_scores_std = np.std(train_scores, axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
    test_scores_mean = np.mean(test_scores, axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
    test_scores_std = np.std(test_scores, axis=&lt;span class="hljs-number"&gt;1&lt;/span&gt;)

    &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; plot:
        plt.figure()
        plt.title(title)
        &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; ylim &lt;span class="hljs-keyword"&gt;is&lt;/span&gt; &lt;span class="hljs-keyword"&gt;not&lt;/span&gt; &lt;span class="hljs-keyword"&gt;None&lt;/span&gt;:
            plt.ylim(*ylim)
        plt.xlabel(&lt;span class="hljs-string"&gt;u"训练样本数"&lt;/span&gt;)
        plt.ylabel(&lt;span class="hljs-string"&gt;u"得分"&lt;/span&gt;)
        plt.gca().invert_yaxis()
        plt.grid()

        plt.fill_between(train_sizes, train_scores_mean - train_scores_std, train_scores_mean + train_scores_std, 
                         alpha=&lt;span class="hljs-number"&gt;0.1&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;"b"&lt;/span&gt;)
        plt.fill_between(train_sizes, test_scores_mean - test_scores_std, test_scores_mean + test_scores_std, 
                         alpha=&lt;span class="hljs-number"&gt;0.1&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;"r"&lt;/span&gt;)
        plt.plot(train_sizes, train_scores_mean, &lt;span class="hljs-string"&gt;'o-'&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;"b"&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;u"训练集上得分"&lt;/span&gt;)
        plt.plot(train_sizes, test_scores_mean, &lt;span class="hljs-string"&gt;'o-'&lt;/span&gt;, color=&lt;span class="hljs-string"&gt;"r"&lt;/span&gt;, label=&lt;span class="hljs-string"&gt;u"交叉验证集上得分"&lt;/span&gt;)

        plt.legend(loc=&lt;span class="hljs-string"&gt;"best"&lt;/span&gt;)

        plt.draw()
        plt.show()
        plt.gca().invert_yaxis()

    midpoint = ((train_scores_mean[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;] + train_scores_std[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;]) + (test_scores_mean[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;] - test_scores_std[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;])) / &lt;span class="hljs-number"&gt;2&lt;/span&gt;
    diff = (train_scores_mean[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;] + train_scores_std[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;]) - (test_scores_mean[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;] - test_scores_std[-&lt;span class="hljs-number"&gt;1&lt;/span&gt;])
    &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; midpoint, diff

plot_learning_curve(clf, &lt;span class="hljs-string"&gt;u"学习曲线"&lt;/span&gt;, X, y)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-28">
                28
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-29">
                29
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-30">
                30
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-31">
                31
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-32">
                32
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-33">
                33
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-34">
                34
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-35">
                35
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-36">
                36
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-37">
                37
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-38">
                38
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-39">
                39
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-40">
                40
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-41">
                41
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-42">
                42
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-43">
                43
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-44">
                44
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-45">
                45
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-46">
                46
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-47">
                47
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-48">
                48
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-49">
                49
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-50">
                50
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-51">
                51
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-52">
                52
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-53">
                53
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadcb155086021-54">
                54
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadcb155086021-55">
                55
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 numpy
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 matplotlib
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 pyplot
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 as
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 learning_curve
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 learning_curve
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-4">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-5">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 用sklearn的learning_curve得到training_score和cv_score，使用matplotlib画出learning curve&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-6">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-function"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-title"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 plot_learning_curve
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-params"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 estimator
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 title
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ylim
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 None
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cv
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 None
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_jobs
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 linspace
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-cn">
                 05
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 20
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 verbose
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plot
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 ""
                </span>
                <span class="crayon-s">
                 "
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-9">
                <span class="crayon-s">
                 画出data在某模型上的learning curve.
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-10">
                <span class="crayon-s">
                 参数解释
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-11">
                <span class="crayon-s">
                 ----------
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-12">
                <span class="crayon-s">
                 estimator : 你用的分类器。
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-13">
                <span class="crayon-s">
                 title : 表格的标题。
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-14">
                <span class="crayon-s">
                 X : 输入的feature，numpy类型
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-15">
                <span class="crayon-s">
                 y : 输入的target vector
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-16">
                <span class="crayon-s">
                 ylim : tuple格式的(ymin, ymax), 设定图像中纵坐标的最低点和最高点
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-17">
                <span class="crayon-s">
                 cv : 做cross-validation的时候，数据分成的份数，其中一份作为cv集，其余n-1份作为training(默认为3份)
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-18">
                <span class="crayon-s">
                 n_jobs : 并行的的任务数(默认1)
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-19">
                <span class="crayon-s">
                 "
                </span>
                <span class="crayon-s">
                 ""
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-20">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 learning_curve
                </span>
                <span class="crayon-sy">
                 (
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-21">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 estimator
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 cv
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 cv
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_jobs
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 n_jobs
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 verbose
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-v">
                 verbose
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-22">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-23">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 mean
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_scores
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-24">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_std
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 std
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_scores
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-25">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 mean
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test_scores
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-26">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_std
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 std
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test_scores
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 axis
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-27">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-28">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plot
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-29">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 figure
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-30">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 title
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 title
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-31">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ylim
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 is
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 not
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 None
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-32">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylim
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-v">
                 ylim
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-33">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 xlabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "训练样本数"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-34">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 ylabel
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "得分"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-35">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 gca
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 invert_yaxis
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-36">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 grid
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-37">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-38">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fill_between
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_std
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_std
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-39">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "b"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-40">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fill_between
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_std
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_std
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-41">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 alpha
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "r"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-42">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'o-'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "b"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "训练集上得分"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-43">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 plot
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_sizes
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'o-'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 color
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "r"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 label
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "交叉验证集上得分"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-44">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-45">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 legend
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 loc
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "best"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-46">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-47">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 draw
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-48">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 show
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-49">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 plt
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 gca
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 invert_yaxis
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-50">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-51">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 midpoint
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_std
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_std
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-52">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diff
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 train_scores_mean
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_scores_std
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test_scores_mean
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 test_scores_std
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-53">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 midpoint
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 diff
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadcb155086021-54">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadcb155086021-55">
                <span class="crayon-e">
                 plot_learning_curve
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-i">
                 u
                </span>
                <span class="crayon-s">
                 "学习曲线"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.1086 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
         <li>
          21
         </li>
         <li>
          22
         </li>
         <li>
          23
         </li>
         <li>
          24
         </li>
         <li>
          25
         </li>
         <li>
          26
         </li>
         <li>
          27
         </li>
         <li>
          28
         </li>
         <li>
          29
         </li>
         <li>
          30
         </li>
         <li>
          31
         </li>
         <li>
          32
         </li>
         <li>
          33
         </li>
         <li>
          34
         </li>
         <li>
          35
         </li>
         <li>
          36
         </li>
         <li>
          37
         </li>
         <li>
          38
         </li>
         <li>
          39
         </li>
         <li>
          40
         </li>
         <li>
          41
         </li>
         <li>
          42
         </li>
         <li>
          43
         </li>
         <li>
          44
         </li>
         <li>
          45
         </li>
         <li>
          46
         </li>
         <li>
          47
         </li>
         <li>
          48
         </li>
         <li>
          49
         </li>
         <li>
          50
         </li>
         <li>
          51
         </li>
         <li>
          52
         </li>
         <li>
          53
         </li>
         <li>
          54
         </li>
         <li>
          55
         </li>
        </ul>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/learning_curve.png?imageView/2/w/600/q/100"/>
        </p>
        <p>
         在实际数据上看，我们得到的learning curve没有理论推导的那么光滑哈，但是可以大致看出来，训练集和交叉验证集上的得分曲线走势还是符合预期的。
        </p>
        <p>
         目前的曲线看来，我们的model并不处于overfitting的状态(overfitting的表现一般是训练集上得分高，而交叉验证集上要低 很多，中间的gap比较大)。因此我们可以再做些feature engineering的工作，添加一些新产出的特征或者组合特征到模型中。
        </p>
        <h2 id="10模型融合model-ensemble">
         10.模型融合(model ensemble)
        </h2>
        <p>
         好了，终于到这一步了，我们要祭出机器学习/数据挖掘上通常最后会用到的大杀器了。恩，模型融合。
        </p>
        <p>
         『强迫症患者』打算继续喊喊口号…
         <br/>
         <strong>
          『模型融合(model ensemble)很重要！』
         </strong>
         <br/>
         <strong>
          『模型融合(model ensemble)很重要！』
         </strong>
         <br/>
         <strong>
          『模型融合(model ensemble)很重要！』
         </strong>
         <br/>
         重要的事情说三遍，恩，噢啦。
        </p>
        <p>
         先解释解释，一会儿再回到我们的问题上哈。
         <br/>
         啥叫模型融合呢，我们还是举几个例子直观理解一下好了。
        </p>
        <p>
         大家都看过知识问答的综艺节目中，求助现场观众时候，让观众投票，最高的答案作为自己的答案的形式吧，每个人都有一个判定结果，最后我们相信答案在大多数人手里。
        </p>
        <p>
         再通俗一点举个例子。你和你班某数学大神关系好，每次作业都『模仿』他的，于是绝大多数情况下，他做对了，你也对了。突然某一天大神脑子犯糊涂，手一抖，写错了一个数，于是…恩，你也只能跟着错了。
         <br/>
         我们再来看看另外一个场景，你和你班5个数学大神关系都很好，每次都把他们作业拿过来，对比一下，再『自己做』，那你想想，如果哪天某大神犯糊涂了，写错了，but另外四个写对了啊，那你肯定相信另外4人的是正确答案吧？
        </p>
        <p>
         最简单的模型融合大概就是这么个意思，比如分类问题，当我们手头上
         <strong>
          有一堆在同一份数据集上训练得到的分类器(比如logistic regression，SVM，KNN，random forest，神经网络)
         </strong>
         ，那我们让他们
         <strong>
          都分别去做判定，然后对结果做投票统计，取票数最多的结果为最后结果
         </strong>
         。
        </p>
        <p>
         bingo，问题就这么完美的解决了。
        </p>
        <p>
         模型融合可以比较好地缓解，训练过程中产生的过拟合问题，从而对于结果的准确度提升有一定的帮助。
        </p>
        <p>
         话说回来，回到我们现在的问题。你看，我们现在只讲了logistic regression，如果我们还想用这个融合思想去提高我们的结果，我们该怎么做呢？
        </p>
        <p>
         既然这个时候模型没得选，那咱们就在数据上动动手脚咯。大家想想，如果模型出现过拟合现在，一定是在我们的训练上出现拟合过度造成的对吧。
        </p>
        <p>
         那我们干脆就不要用全部的训练集，每次取训练集的一个subset，做训练，这样，我们虽然用的是同一个机器学习算法，但是得到的模型却是不一样 的；同时，因为我们没有任何一份子数据集是全的，因此即使出现过拟合，也是在子训练集上出现过拟合，而不是全体数据上，这样做一个融合，可能对最后的结果 有一定的帮助。对，这就是常用的Bagging。
        </p>
        <p>
         我们用scikit-learn里面的Bagging来完成上面的思路，过程非常简单。代码如下：
        </p>
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685d6daadda568848415" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="hljs-keyword"&gt;from&lt;/span&gt; sklearn.ensemble &lt;span class="hljs-keyword"&gt;import&lt;/span&gt; BaggingRegressor

train_df = df.filter(regex=&lt;span class="hljs-string"&gt;'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title'&lt;/span&gt;)
train_np = train_df.as_matrix()

&lt;span class="hljs-comment"&gt;# y即Survival结果&lt;/span&gt;
y = train_np[:, &lt;span class="hljs-number"&gt;0&lt;/span&gt;]

&lt;span class="hljs-comment"&gt;# X即特征属性值&lt;/span&gt;
X = train_np[:, &lt;span class="hljs-number"&gt;1&lt;/span&gt;:]

&lt;span class="hljs-comment"&gt;# fit到BaggingRegressor之中&lt;/span&gt;
clf = linear_model.LogisticRegression(C=&lt;span class="hljs-number"&gt;1.0&lt;/span&gt;, penalty=&lt;span class="hljs-string"&gt;'l1'&lt;/span&gt;, tol=&lt;span class="hljs-number"&gt;1e-6&lt;/span&gt;)
bagging_clf = BaggingRegressor(clf, n_estimators=&lt;span class="hljs-number"&gt;20&lt;/span&gt;, max_samples=&lt;span class="hljs-number"&gt;0.8&lt;/span&gt;, max_features=&lt;span class="hljs-number"&gt;1.0&lt;/span&gt;, bootstrap=&lt;span class="hljs-keyword"&gt;True&lt;/span&gt;, bootstrap_features=&lt;span class="hljs-keyword"&gt;False&lt;/span&gt;, n_jobs=-&lt;span class="hljs-number"&gt;1&lt;/span&gt;)
bagging_clf.fit(X, y)

test = df_test.filter(regex=&lt;span class="hljs-string"&gt;'Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title'&lt;/span&gt;)
predictions = bagging_clf.predict(test)
result = pd.DataFrame({&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;:data_test[&lt;span class="hljs-string"&gt;'PassengerId'&lt;/span&gt;].as_matrix(), &lt;span class="hljs-string"&gt;'Survived'&lt;/span&gt;:predictions.astype(np.int32)})
result.to_csv(&lt;span class="hljs-string"&gt;"/Users/HanXiaoyang/Titanic_data/logistic_regression_bagging_predictions.csv"&lt;/span&gt;, index=&lt;span class="hljs-keyword"&gt;False&lt;/span&gt;)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685d6daadda568848415-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685d6daadda568848415-20">
                20
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685d6daadda568848415-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 sklearn
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 ensemble
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 BaggingRegressor
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-2">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-3">
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived|Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-4">
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_df
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-5">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-6">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # y即Survival结果&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-7">
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-8">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-9">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # X即特征属性值&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-10">
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 train_np
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-11">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-12">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-comment"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # fit到BaggingRegressor之中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-13">
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 linear_model
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 LogisticRegression
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 C
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 penalty
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'l1'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 tol
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1e
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-cn">
                 6
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-14">
                <span class="crayon-v">
                 bagging_clf
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 BaggingRegressor
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 clf
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_estimators
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 20
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 max_samples
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.8
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 max_features
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 bootstrap
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 bootstrap_features
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 False
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 n_jobs
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-number"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-15">
                <span class="crayon-v">
                 bagging_clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 fit
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 X
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 y
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-16">
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-17">
                <span class="crayon-v">
                 test
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 df_test
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 filter
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 regex
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Age_.*|SibSp|Parch|Fare_.*|Cabin_.*|Embarked_.*|Sex_.*|Pclass.*|Mother|Child|Family|Title'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-18">
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 bagging_clf
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 predict
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 test
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685d6daadda568848415-19">
                <span class="crayon-v">
                 result
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 pd
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 DataFrame
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 data_test
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'PassengerId'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 as_matrix
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 'Survived'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-v">
                 predictions
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 astype
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 np
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 int32
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685d6daadda568848415-20">
                <span class="crayon-v">
                 result
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 to_csv
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-string"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "/Users/HanXiaoyang/Titanic_data/logistic_regression_bagging_predictions.csv"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 index
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "hljs-keyword"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 False
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0597 seconds] -->
        <p>
        </p>
        <ul class="pre-numbering">
         <li>
          1
         </li>
         <li>
          2
         </li>
         <li>
          3
         </li>
         <li>
          4
         </li>
         <li>
          5
         </li>
         <li>
          6
         </li>
         <li>
          7
         </li>
         <li>
          8
         </li>
         <li>
          9
         </li>
         <li>
          10
         </li>
         <li>
          11
         </li>
         <li>
          12
         </li>
         <li>
          13
         </li>
         <li>
          14
         </li>
         <li>
          15
         </li>
         <li>
          16
         </li>
         <li>
          17
         </li>
         <li>
          18
         </li>
         <li>
          19
         </li>
         <li>
          20
         </li>
        </ul>
        <p>
         然后你再Make a submission，恩，发现对结果还是有帮助的。
        </p>
        <p>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/result_4.jpeg?imageView/2/w/700/q/100"/>
        </p>
        <h2 id="11总结">
         11.总结
        </h2>
        <p>
         文章稍微有点长，非常感谢各位耐心看到这里。
         <br/>
         总结的部分，我就简短写几段，出现的话，很多在文中有对应的场景，大家有兴趣再回头看看。
        </p>
        <p>
         对于任何的机器学习问题，不要一上来就追求尽善尽美，
         <strong>
          先用自己会的算法撸一个baseline的model出来，再进行后续的分析步骤，一步步提高
         </strong>
         。
        </p>
        <p>
         在问题的结果过程中：
         <br/>
         *
         <strong>
          『对数据的认识太重要了！』
         </strong>
         <br/>
         *
         <strong>
          『数据中的特殊点/离群点的分析和处理太重要了！』
         </strong>
         <br/>
         *
         <strong>
          『特征工程(feature engineering)太重要了！』
         </strong>
         <br/>
         *
         <strong>
          『模型融合(model ensemble)太重要了！』
         </strong>
        </p>
        <p>
         本文中用机器学习解决问题的过程大概如下图所示：
         <br/>
         <img src="http://7xo0y8.com1.z0.glb.clouddn.com/2_titanic/process.png?imageView/2/w/700/q/100"/>
        </p>
        <h2 id="12关于数据和代码">
         12.关于数据和代码
        </h2>
        <p>
         本文中的数据和代码已经上传至
         <a href="https://github.com/HanXiaoyang/Kaggle_Titanic">
          github
         </a>
         中，欢迎大家下载和自己尝试。
        </p>
       </div>
       <p>
       </p>
       <p>
        投稿作者：
        <a href="http://blog.csdn.net/han_xiaoyang?viewmode=contents">
         寒小阳
        </a>
        &amp;&amp;
        <a href="http://blog.csdn.net/longxinchen_ml?viewmode=list">
         龙心尘
        </a>
        <br/>
        出处：
        <br/>
        <a href="http://blog.csdn.net/han_xiaoyang/article/details/49797143">
         http://blog.csdn.net/han_xiaoyang/article/details/49797143
        </a>
        <br/>
        <a href="http://blog.csdn.net/longxinchen_ml/article/details/49798139">
         http://blog.csdn.net/longxinchen_ml/article/details/49798139
        </a>
        <br/>
        声明：版权所有，转载请联系作者并注明出处，谢谢。
       </p>
       <p>
       </p>
       <p>
        <strong>
         如果您也有兴趣在数盟发布文章，欢迎联系我们：
         <a href="mailto:contact@dataunion.org" target="_blank">
          contact@dataunion.org
         </a>
        </strong>
       </p>
       <p>
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24663.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/095356be8cb4z9ke9389kd-204x200.jpeg"/>
        </a>
        <a class="link" href="http://dataunion.org/24663.html" rel="bookmark" title="人工智能界最强大脑畅谈AI未来之路">
         人工智能界最强大脑畅谈AI未来之路
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24652.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/02/20150522141422337-265x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24652.html" rel="bookmark" title="重磅 | MIT与谷歌专家合著论文：机器学习和神经科学的相互启发与融合（附论文）">
         重磅 | MIT与谷歌专家合著论文：机器学习和神经科学的相互启发与融合（附论文）
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24616.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/224806wllbe6tcimyyi9xt-300x167.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24616.html" rel="bookmark" title="微软人工智能计划背后的华人力量">
         微软人工智能计划背后的华人力量
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24562.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/8aac7ceb921d1684f06e6f65e2c1f224-300x173.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24562.html" rel="bookmark" title="各位大佬，别再拿人工智能当春药了！">
         各位大佬，别再拿人工智能当春药了！
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F21477.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/21477.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/21477.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>